<?php
/**
 * Created by PhpStorm.
 * User: andy
 * Date: 2019/11/11
 * Time: 下午12:11
 */
namespace app\http\middleware;

use think\facade\Request;
use think\facade\Session;

class CheckAdminLogin
{
    public function handle($request, \Closure $next)
    {
        $sessionAdminId = Session::get('UID');
        if (empty($sessionAdminId) && !Request::isAjax()){
            return redirect("/control/public/login");
        }
        if (empty($sessionAdminId) && Request::isAjax()){
            return redirect("/control/public/jump",merror("您还没有登录！",'/control/public/login'));
        }

        return $next($request);
    }
}